/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.buzzwords.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author potlow
 */
@Entity
@Table(name = "ratings")
@NamedQueries({@NamedQuery(name = "Rating.findAll", query = "SELECT r FROM Rating r"), @NamedQuery(name = "Rating.findById", query = "SELECT r FROM Rating r WHERE r.id = :id"), @NamedQuery(name = "Rating.findByRating", query = "SELECT r FROM Rating r WHERE r.rating = :rating")})
public class Rating implements Serializable {

    private static final long serialVersionUID = 1L;
    private Integer id;
    private boolean rating;
    private List<BuzzwordJPO> buzzwords;

    public Rating() {
    }

    public Rating(Integer id) {
        this.id = id;
    }

    public Rating(boolean rating) {
        this.rating = rating;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic(optional = false)
    @Column(name = "rating")
    public boolean getRating() {
        return rating;
    }

    public void setRating(boolean rating) {
        this.rating = rating;
    }

    @ManyToMany(mappedBy="ratings")
    public List<BuzzwordJPO> getBuzzword() {
        return buzzwords;
    }

    public void setBuzzword(List<BuzzwordJPO> buzzwords) {
        this.buzzwords = buzzwords;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rating)) {
            return false;
        }
        Rating other = (Rating) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.buzzwords.persist.Rating[id=" + id + "]";
    }

}
